package javax.microedition.io.file;

import android.os.StatFs;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.util.Enumeration;
import java.util.Vector;

public class FileConnectionImpl
  implements FileConnection
{
  DataInputStream dis;
  DataOutputStream dos;
  File file;
  InputStream is;
  OutputStream os;
  String url;

  public FileConnectionImpl(String paramString, int paramInt)
  {
    this.url = paramString;
    int i = "file://".length();
    String str = paramString.substring(i);
    File localFile = new File(str);
    this.file = localFile;
  }

  public long availableSize()
  {
    String str = getPath();
    StatFs localStatFs = new StatFs(str);
    int i = localStatFs.getAvailableBlocks();
    int j = localStatFs.getBlockSize();
    return (i * j);
  }

  public boolean canRead()
  {
    return this.file.canRead();
  }

  public boolean canWrite()
  {
    return this.file.canWrite();
  }

  public void close()
    throws IOException
  {
    if (this.dos != null)
    {
      this.dos.close();
    }
    if (this.dis != null)
    {
      this.dis.close();
    }
    if (this.os != null)
    {
      this.os.close();
    }
    if (this.is == null)
      return;
    this.is.close();
  }

  public void create()
    throws IOException
  {
    this.file.createNewFile();
  }

  public void delete()
    throws IOException
  {
    this.file.delete();
  }

  public long directorySize(boolean paramBoolean)
    throws IOException
  {
    return 0L;
  }

  public boolean exists()
  {
    return this.file.exists();
  }

  public long fileSize()
    throws IOException
  {
    return this.file.length();
  }

  public String getName()
  {
    String str1 = this.file.getName();
    int i = str1.lastIndexOf(47);
    if (i == -1);
    for (String str2 = str1; ; str2 = str1.substring(i))
      return str2;
  }

  public String getPath()
  {
    String str1 = this.file.getPath();
    int i = str1.lastIndexOf(47);
    if (i == -1);
    for (String str2 = str1; ; str2 = str1.substring(0, i))
      return str2;
  }

  public String getURL()
  {
    return this.url;
  }

  public boolean isDirectory()
  {
    return this.file.isDirectory();
  }

  public boolean isHidden()
  {
    return isHidden();
  }

  public boolean isOpen()
  {
	  if (this.dis == null) {
		  if (this.dos == null) {
			  if (this.is == null) {
				  if (this.os == null)
					  return false;
			  }
		  }
	  }
	  return true;
  }

  public long lastModified()
  {
    return this.file.lastModified();
  }

  public Enumeration list()
    throws IOException
  {
    String[] list = this.file.list();
    Vector localVector = new Vector(list.length);
    for (int j = 0; j < list.length; j++) {
    	localVector.addElement(list[j]);
	}
    return localVector.elements();
  }

  public Enumeration list(String paramString, boolean paramBoolean)
    throws IOException
  {
    return null;
  }

  public void mkdir()
    throws IOException
  {
    this.file.mkdir();
  }

  public DataInputStream openDataInputStream()
    throws IOException
  {
    InputStream localInputStream = openInputStream();
    DataInputStream localDataInputStream = new DataInputStream(localInputStream);
    this.dis = localDataInputStream;
    return this.dis;
  }

  public DataOutputStream openDataOutputStream()
    throws IOException
  {
    OutputStream localOutputStream = openOutputStream();
    DataOutputStream localDataOutputStream = new DataOutputStream(localOutputStream);
    this.dos = localDataOutputStream;
    return this.dos;
  }

  public InputStream openInputStream()
    throws IOException
  {
    File localFile = this.file;
    FileInputStream localFileInputStream = new FileInputStream(localFile);
    this.is = localFileInputStream;
    return this.is;
  }

  public OutputStream openOutputStream()
    throws IOException
  {
    File localFile = this.file;
    FileOutputStream localFileOutputStream = new FileOutputStream(localFile);
    this.os = localFileOutputStream;
    return this.os;
  }

  public OutputStream openOutputStream(long paramLong)
    throws IOException
  {
    File localFile = this.file;
    RandomAccessFile localRandomAccessFile = new RandomAccessFile(localFile, "rw");
    localRandomAccessFile.seek(paramLong);
    RandomAccessFileOutputStream localRandomAccessFileOutputStream = new RandomAccessFileOutputStream(localRandomAccessFile);
    this.os = localRandomAccessFileOutputStream;
    return this.os;
  }

  public void rename(String paramString)
    throws IOException
  {
    String str = getPath();
    File localFile = new File(str, paramString);
    this.file.renameTo(localFile);
  }

  public void setFileConnection(String paramString)
    throws IOException
  {
  }

  public void setHidden(boolean paramBoolean)
    throws IOException
  {
  }

  public void setReadable(boolean paramBoolean)
    throws IOException
  {
  }

  public void setWritable(boolean paramBoolean)
    throws IOException
  {
  }

  public long totalSize()
  {
    return 0L;
  }

  public void truncate(long paramLong)
    throws IOException
  {
  }

  public long usedSize()
  {
    return 0L;
  }
}